package question3;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class IteraterDemo {
    public static void main(String[] args) {
        Collection<String> list = new ArrayList<>();
        list.add("JavaEE 企业级开发指南");
        list.add("Oracle 高级编程");
        list.add("MySQL 从入门到精通");
        list.add("Java 架构师之路");
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String s =  iterator.next();
            System.out.println(s);
        }
        System.out.println("-----------");
        Iterator<String> iterator1 = list.iterator();
        while (iterator1.hasNext()) {
            String s =  iterator1.next();
            if (s.length()<=10){
                System.out.println(s);
            }
        }
        System.out.println("-----------");
        Iterator<String> iterator3 = list.iterator();
        while (iterator3.hasNext()) {
            String s =  iterator3.next();
            if (s.contains("Java")){
                System.out.println(s);
            }
        }

        Iterator<String> iterator4 = list.iterator();
        while (iterator4.hasNext()) {
            String s =  iterator4.next();
            if (s.contains("Oracle")){
                iterator4.remove();
            }
        }
        System.out.println("-----------");
        list.forEach( (a)-> System.out.println(a) );
    }
}
